cars dataScatterplot of cars data
I will work with R’s internal dataset on cars: cars.
There are two variables in the dataset, speed [speed] and distance
[dist] this is what they look like.
We require two things:
I will work with the speed variable. Let me consider two distinct hypotheses though this is not entirely proper in the sense that any given application of hypothesis testing should have a clear hypothesis about the variable of interest rather than waffling amongst two as I will. I do so only for illustrative purposes. To begin, I need to specify both the hypothesis and the confidence level that I intend to use to evaluate it.
The \(t\) equation is given by:
\[t=\frac{\overline{x} - \mu}{\frac{s}{\sqrt{n}}}\]
One further algebraic manipulation before starting. Let’s solve for \(\overline{x}\).
\[\mu + t\left(\frac{s}{\sqrt{n}}\right)=\overline{x}\]
This fully defines the parts we require and the core problem
Mean SD SE N
1 15.4 5.287644 0.7477858 50
\[t = \frac{15.4 - 17}{\frac{s}{\sqrt{n}}} = \frac{-1.6}{0.7478}=-2.14\]
Critical Values
P(-1.677 < X < 1.677) = 0.9
1 - P(-1.677 < X < 1.677) = 0.1
Result
P(X < -2.14) = 0.019
P(X > 2.14) = 0.019
P(-2.14 < X < 2.14) = 0.963
1 - P(-2.14 < X < 2.14) = 0.037
Knowing only the sample size, 50, is sufficient to determine what \(t\) must be to reject a mean of 17 in favor of the alternative that the true mean is not 17. With 0.9 probability, this implies two boundaries; either the true mean is smaller than 17, with 0.05 probability spanning 0 to 0.05 and it is bigger than 17 with 0.05 probability spanning 0.95 to 1 so that the interior range represents 0.9 probability as required.
Critical Values: The sample mean would have to be at least \(\pm\) 1.677 standard errors away from 17 to rule out a mean of 17 with 90% confidence.
Result: Our sample mean is 2.14 standard errors away from 17. The probability of something equally or more extreme is 0.037.
Critical Values
P(X < -1.299) = 0.1
P(X > -1.299) = 0.9
Result
P(X < -2.14) = 0.019
P(X > -2.14) = 0.981
Knowing only the sample size, 50, is sufficient to determine what \(t\) must be to reject a mean of 17 or greater in favor of the alternative that the true mean is less than 17. With 0.9 probability, either the true mean is smaller than 17, with 0.1 probability or it is 17 or bigger with 0.9 probability as required.
Critical Values: The sample mean would have to be at most -1.299 standard errors away from 17 to rule out a mean of 17 or greater with 90% confidence.
Result: Our sample mean is -2.14 standard errors away from 17. The probability of something equal or lesser is 0.019.
Critical Values
P(X < -1.299) = 0.1
P(X > -1.299) = 0.9
Result
P(X < -2.14) = 0.019
P(X > -2.14) = 0.981
Knowing only the sample size, 50, is sufficient to determine what \(t\) must be to reject a mean of 17 or greater in favor of the alternative that the true mean is less than 17. With 0.9 probability, either the true mean is smaller than 17, with 0.1 probability or it is 17 or bigger with 0.9 probability as required.
Critical Values: The sample mean would have to be at most -1.299 standard errors away from 17 to rule out a mean of 17 or greater with 90% confidence.
Result: Our sample mean is -2.14 standard errors away from 17. The probability of something equal or greater is 0.981.
t.testAlternative: Two-sided
One Sample t-test
data: cars$speed
t = -2.1397, df = 49, p-value = 0.03739
alternative hypothesis: true mean is not equal to 17
95 percent confidence interval:
13.89727 16.90273
sample estimates:
mean of x
15.4
Alternative: Less
One Sample t-test
data: cars$speed
t = -2.1397, df = 49, p-value = 0.01869
alternative hypothesis: true mean is less than 17
95 percent confidence interval:
-Inf 16.6537
sample estimates:
mean of x
15.4
Alternative: Greater
One Sample t-test
data: cars$speed
t = -2.1397, df = 49, p-value = 0.9813
alternative hypothesis: true mean is greater than 17
95 percent confidence interval:
14.1463 Inf
sample estimates:
mean of x
15.4